package com.newjiabo.web.controller.ski;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newjiabo.common.annotation.Log;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.enums.BusinessType;
import com.newjiabo.ski.domain.SkiCameraman;
import com.newjiabo.ski.service.ISkiCameramanService;
import com.newjiabo.common.utils.poi.ExcelUtil;
import com.newjiabo.common.core.page.TableDataInfo;

/**
 * 摄影师Controller
 *
 * @author CaoMengHui
 * @date 2023-10-18
 */
@Api(tags = "后台;摄影师模块")
@RestController
@RequestMapping("/system/cameraman")
public class SkiCameramanController extends BaseController {
    @Resource
    private ISkiCameramanService skiCameramanService;

    /**
     * 查询摄影师列表
     */
    @ApiOperation(value = "查询摄影师列表")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkiCameraman skiCameraman) {
        startPage();
        List<SkiCameraman> list = skiCameramanService.selectSkiCameramanList(skiCameraman);
        return getDataTable(list);
    }

    /**
     * 导出摄影师列表
     */
    @ApiOperation(value = "导出摄影师列表")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:export')")
    @Log(title = "摄影师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkiCameraman skiCameraman) {
        List<SkiCameraman> list = skiCameramanService.selectSkiCameramanList(skiCameraman);
        ExcelUtil<SkiCameraman> util = new ExcelUtil<SkiCameraman>(SkiCameraman.class);
        util.exportExcel(response, list, "摄影师数据");
    }

    /**
     * 获取摄影师详细信息
     */
    @ApiOperation(value = "获取摄影师详细信息")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(skiCameramanService.info(id));
    }

    /**
     * 新增摄影师
     */
    @ApiOperation(value = "新增摄影师")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:add')")
    @Log(title = "摄影师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkiCameraman skiCameraman) {
        return toAjax(skiCameramanService.insertSkiCameraman(skiCameraman));
    }

    /**
     * 修改摄影师
     */
    @ApiOperation(value = "修改摄影师")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:edit')")
    @Log(title = "摄影师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkiCameraman skiCameraman) {
        return toAjax(skiCameramanService.updateSkiCameraman(skiCameraman));
    }

    /**
     * 删除摄影师
     */
    @ApiOperation(value = "删除摄影师")
    @PreAuthorize("@ss.hasPermi('ski:cameraman:remove')")
    @Log(title = "摄影师", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(skiCameramanService.deleteSkiCameramanByIds(ids));
    }
}
